package task

import(
	"nightowl/logger"
	. "nightowl/config"
	. "nightowl/http"
	"time"
)
func init(){

}
func registry(){
	client := ENV_CONFIG.EdgeClientEnv
	params := map[string] interface{}{}
	params["name"] = client.Name
	params["code"] = client.Code
	params["server"] = client.Server
	params["loc"] = client.Loc
	params["note"] = client.Note
	params["resourcePoolCode"] = client.ResourcePoolCode
	
	logger.Info("registry|time:%s:|client:%s\n", time.Now().Format("2006-01-02 15:04:05"), params)
	ApiRequest("edge-client", "registry",
		RequestParams{
		Params: params, 
	})
}
func startRegistryClient(){	
	logger.Info("task|startRegistryClient|time:%s", time.Now().Format("2006-01-02 15:04:05"))
	ticker := time.NewTicker(5 * time.Second) 
	defer ticker.Stop() // 防止资源泄漏
	for {
		select {
		case <-ticker.C:
			registry()
		}
	}
}
func Start(){
	go startRegistryClient()
}